package ext.tianma.bom.service.sqe;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;


@Controller
@RequestMapping({ "/sqe"})
public class SQEMaterialController {
	@RequestMapping(value = "/sqeMaterial", method = {
			RequestMethod.POST, RequestMethod.GET })
	public void getSQEMaterial(
			@RequestParam(value = "number", required = true) String number,
			@RequestParam(value = "view", required = true) String view,
			HttpServletResponse response) throws Exception {
		boolean enforce = wt.session.SessionServerHelper.manager
				.setAccessEnforced(false);
		PrintWriter out = response.getWriter();
		response.setContentType("text/html;charset=UTF-8");
		try {
			String result = SQEMaterialService.getShowData(number.trim(), view.trim()).toString();
			out.print(result);
		} catch (Throwable e) {
			e.printStackTrace();
		} finally {
			wt.session.SessionServerHelper.manager.setAccessEnforced(enforce);
		}
	}
	
	
	@RequestMapping(value = "/sqeMaterialExcel", method = {
			RequestMethod.POST, RequestMethod.GET })
	public void getSQEMaterialExcel(
			@RequestParam(value = "number", required = true) String number,
			@RequestParam(value = "view", required = true) String view,
			HttpServletResponse response) throws Exception {
		boolean enforce = wt.session.SessionServerHelper.manager
				.setAccessEnforced(false);
		PrintWriter out = response.getWriter();
		response.setContentType("text/html;charset=UTF-8");
		try {
			String result = SQEMaterialService.getExcelData(number.trim(), view.trim()).toString();
			out.print(result);
		} catch (Throwable e) {
			e.printStackTrace();
		} finally {
			wt.session.SessionServerHelper.manager.setAccessEnforced(enforce);
		}
	}
}


